﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;

namespace GSSoftSL.Web.Models
{
    public partial class DiemSo
    {
        public Guid KhoaHocId { get; set; }
        //public List<CotDiemInfo> CotDiems { get; set; }
        public int[] Cots { get; set; }
        public List<HocVienDiem> Diems { get; set; }
    }

    public partial class CotDiemInfo : INotifyPropertyChanged
    {
        public static Action CallBack;

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }
        
        private int _sTT;
        [Display(AutoGenerateField = false)]
        public int STT
        {
            get
            {
                return _sTT;
            }
            set
            {
                if (_sTT == value)
                {
                    return;
                }
                _sTT = value;
                NotifyPropertyChanged("STT");
            }
        }
        
        private string _tenCot;
        [Display(Name = "Tên cột")]
        public string TenCot
        {
            get
            {
                return _tenCot;
            }
            set
            {
                if (_tenCot == value)
                {
                    return;
                }
                _tenCot = value;
                NotifyPropertyChanged("TenCot");
            }
        }

        private DateTime? _ngayKiemTra;
        [Display(Name = "Ngày kiểm tra")]
        public DateTime? NgayKiemTra
        {
            get
            {
                return _ngayKiemTra;
            }
            set
            {
                if (_ngayKiemTra == value)
                {
                    return;
                }
                _ngayKiemTra = value;
                NotifyPropertyChanged("NgayKiemTra");
            }
        }
        
        private Guid _khoaHocId;
        public Guid KhoaHocId
        {
            get
            {
                return _khoaHocId;
            }
            set
            {
                if (_khoaHocId == value)
                {
                    return;
                }
                _khoaHocId = value;
                NotifyPropertyChanged("KhoaHocId");
            }
        }
        
        private bool _isSelected = false;
        [Display(Name = "Chọn")]
        public bool IsSelected
        {
            get
            {
                return _isSelected;
            }
            set
            {
                if (_isSelected == value)
                {
                    return;
                }
                _isSelected = value;
                NotifyPropertyChanged("IsSelected");
                if (CallBack != null)
                    CallBack();
            }
        }

        [Display(AutoGenerateField = false)]
        public KhoaHocCotDiem KhoaHocCotDiem { get; set; }
        //public int STT { get; set; }
        //public string TenCot { get; set; }
    }

    public class DiemSoContractResolver : DefaultContractResolver
    {
        private readonly string[] _cots;

        public DiemSoContractResolver(string[] cots)
        {
            _cots = cots;
        }

        protected override IList<JsonProperty> CreateProperties(Type type, MemberSerialization memberSerialization)
        {
            IList<JsonProperty> properties = base.CreateProperties(type, memberSerialization);
            if (type == typeof(HocVienDiem))
            {
                properties = properties.Where(n => _cots.Contains(n.PropertyName)).ToList();
            }
            return properties;
        }

        protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
        {
            var property = base.CreateProperty(member, memberSerialization);
            return property;
        }
    }


    public partial class HocVienDiem : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String info)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(info));
            }
        }

        private string _maHV;
        public string MaHV
        {
            get
            {
                return _maHV;
            }
            set
            {
                if (_maHV == value)
                {
                    return;
                }
                _maHV = value;
                NotifyPropertyChanged("MaHV");
            }
        }

        private string _hoTen;
        public string HoTen
        {
            get
            {
                return _hoTen;
            }
            set
            {
                if (_hoTen == value)
                {
                    return;
                }
                _hoTen = value;
                NotifyPropertyChanged("HoTen");
            }
        }

        private decimal? _cot1;
        public decimal? Cot1
        {
            get
            {
                return _cot1;
            }
            set
            {
                if (_cot1 == value)
                {
                    return;
                }
                _cot1 = value;
                NotifyPropertyChanged("Cot1");
            }
        }

        private decimal? _cot2;
        public decimal? Cot2
        {
            get
            {
                return _cot2;
            }
            set
            {
                if (_cot2 == value)
                {
                    return;
                }
                _cot2 = value;
                NotifyPropertyChanged("Cot2");
            }
        }

        private decimal? _cot3;
        public decimal? Cot3
        {
            get
            {
                return _cot3;
            }
            set
            {
                if (_cot3 == value)
                {
                    return;
                }
                _cot3 = value;
                NotifyPropertyChanged("Cot3");
            }
        }

        private decimal? _cot4;
        public decimal? Cot4
        {
            get
            {
                return _cot4;
            }
            set
            {
                if (_cot4 == value)
                {
                    return;
                }
                _cot4 = value;
                NotifyPropertyChanged("Cot4");
            }
        }

        private decimal? _cot5;
        public decimal? Cot5
        {
            get
            {
                return _cot5;
            }
            set
            {
                if (_cot5 == value)
                {
                    return;
                }
                _cot5 = value;
                NotifyPropertyChanged("Cot5");
            }
        }

        private decimal? _cot6;
        public decimal? Cot6
        {
            get
            {
                return _cot6;
            }
            set
            {
                if (_cot6 == value)
                {
                    return;
                }
                _cot6 = value;
                NotifyPropertyChanged("Cot6");
            }
        }

        private decimal? _cot7;
        public decimal? Cot7
        {
            get
            {
                return _cot7;
            }
            set
            {
                if (_cot7 == value)
                {
                    return;
                }
                _cot7 = value;
                NotifyPropertyChanged("Cot7");
            }
        }

        private decimal? _cot8;
        public decimal? Cot8
        {
            get
            {
                return _cot8;
            }
            set
            {
                if (_cot8 == value)
                {
                    return;
                }
                _cot8 = value;
                NotifyPropertyChanged("Cot8");
            }
        }

        private decimal? _cot9;
        public decimal? Cot9
        {
            get
            {
                return _cot9;
            }
            set
            {
                if (_cot9 == value)
                {
                    return;
                }
                _cot9 = value;
                NotifyPropertyChanged("Cot9");
            }
        }

        private decimal? _cot10;
        public decimal? Cot10
        {
            get
            {
                return _cot10;
            }
            set
            {
                if (_cot10 == value)
                {
                    return;
                }
                _cot10 = value;
                NotifyPropertyChanged("Cot10");
            }
        }

        private decimal? _cot11;
        public decimal? Cot11
        {
            get
            {
                return _cot11;
            }
            set
            {
                if (_cot11 == value)
                {
                    return;
                }
                _cot11 = value;
                NotifyPropertyChanged("Cot11");
            }
        }

        private decimal? _cot12;
        public decimal? Cot12
        {
            get
            {
                return _cot12;
            }
            set
            {
                if (_cot12 == value)
                {
                    return;
                }
                _cot12 = value;
                NotifyPropertyChanged("Cot12");
            }
        }

        private decimal? _cot13;
        public decimal? Cot13
        {
            get
            {
                return _cot13;
            }
            set
            {
                if (_cot13 == value)
                {
                    return;
                }
                _cot13 = value;
                NotifyPropertyChanged("Cot13");
            }
        }

        private decimal? _cot14;
        public decimal? Cot14
        {
            get
            {
                return _cot14;
            }
            set
            {
                if (_cot14 == value)
                {
                    return;
                }
                _cot14 = value;
                NotifyPropertyChanged("Cot14");
            }
        }

        private decimal? _cot15;
        public decimal? Cot15
        {
            get
            {
                return _cot15;
            }
            set
            {
                if (_cot15 == value)
                {
                    return;
                }
                _cot15 = value;
                NotifyPropertyChanged("Cot15");
            }
        }

        private decimal? _cot16;
        public decimal? Cot16
        {
            get
            {
                return _cot16;
            }
            set
            {
                if (_cot16 == value)
                {
                    return;
                }
                _cot16 = value;
                NotifyPropertyChanged("Cot16");
            }
        }

        private decimal? _cot17;
        public decimal? Cot17
        {
            get
            {
                return _cot17;
            }
            set
            {
                if (_cot17 == value)
                {
                    return;
                }
                _cot17 = value;
                NotifyPropertyChanged("Cot17");
            }
        }

        private decimal? _cot18;
        public decimal? Cot18
        {
            get
            {
                return _cot18;
            }
            set
            {
                if (_cot18 == value)
                {
                    return;
                }
                _cot18 = value;
                NotifyPropertyChanged("Cot18");
            }
        }

        private decimal? _cot19;
        public decimal? Cot19
        {
            get
            {
                return _cot19;
            }
            set
            {
                if (_cot19 == value)
                {
                    return;
                }
                _cot19 = value;
                NotifyPropertyChanged("Cot19");
            }
        }

        private decimal? _cot20;
        public decimal? Cot20
        {
            get
            {
                return _cot20;
            }
            set
            {
                if (_cot20 == value)
                {
                    return;
                }
                _cot20 = value;
                NotifyPropertyChanged("Cot20");
            }
        }

        private decimal? _cot21;
        public decimal? Cot21
        {
            get
            {
                return _cot21;
            }
            set
            {
                if (_cot21 == value)
                {
                    return;
                }
                _cot21 = value;
                NotifyPropertyChanged("Cot21");
            }
        }

        private decimal? _cot22;
        public decimal? Cot22
        {
            get
            {
                return _cot22;
            }
            set
            {
                if (_cot22 == value)
                {
                    return;
                }
                _cot22 = value;
                NotifyPropertyChanged("Cot22");
            }
        }

        private decimal? _cot23;
        public decimal? Cot23
        {
            get
            {
                return _cot23;
            }
            set
            {
                if (_cot23 == value)
                {
                    return;
                }
                _cot23 = value;
                NotifyPropertyChanged("Cot23");
            }
        }

        private decimal? _cot24;
        public decimal? Cot24
        {
            get
            {
                return _cot24;
            }
            set
            {
                if (_cot24 == value)
                {
                    return;
                }
                _cot24 = value;
                NotifyPropertyChanged("Cot24");
            }
        }

        private decimal? _cot25;
        public decimal? Cot25
        {
            get
            {
                return _cot25;
            }
            set
            {
                if (_cot25 == value)
                {
                    return;
                }
                _cot25 = value;
                NotifyPropertyChanged("Cot25");
            }
        }

        private decimal? _cot26;
        public decimal? Cot26
        {
            get
            {
                return _cot26;
            }
            set
            {
                if (_cot26 == value)
                {
                    return;
                }
                _cot26 = value;
                NotifyPropertyChanged("Cot26");
            }
        }

        private decimal? _cot27;
        public decimal? Cot27
        {
            get
            {
                return _cot27;
            }
            set
            {
                if (_cot27 == value)
                {
                    return;
                }
                _cot27 = value;
                NotifyPropertyChanged("Cot27");
            }
        }

        private decimal? _cot28;
        public decimal? Cot28
        {
            get
            {
                return _cot28;
            }
            set
            {
                if (_cot28 == value)
                {
                    return;
                }
                _cot28 = value;
                NotifyPropertyChanged("Cot28");
            }
        }

        private decimal? _cot29;
        public decimal? Cot29
        {
            get
            {
                return _cot29;
            }
            set
            {
                if (_cot29 == value)
                {
                    return;
                }
                _cot29 = value;
                NotifyPropertyChanged("Cot29");
            }
        }

        private decimal? _cot30;
        public decimal? Cot30
        {
            get
            {
                return _cot30;
            }
            set
            {
                if (_cot30 == value)
                {
                    return;
                }
                _cot30 = value;
                NotifyPropertyChanged("Cot30");
            }
        }

    }
}